<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="../inc/TagLibs.jsp"%>
<c:set var="pageTitle" value="项目价格目录" />
<c:if test="${estType=='CLIENT'}">
	<c:if test="${currentUser.user.userType==1 || fn:indexOf(currentUser.privs,';CLIE_PRIC;')!=-1 && fn:indexOf(currentUser.privs,';NO_PRIC_EDIT;')==-1}"><c:set var="canOper" value="Y" /></c:if>
</c:if>
<c:if test="${estType=='PROVIDER'}">
	<c:if test="${currentUser.user.userType==1 || fn:indexOf(currentUser.privs,';PROV_PRIC;')!=-1 && fn:indexOf(currentUser.privs,';NO_PRIC_EDIT;')==-1}"><c:set var="canOper" value="Y" /></c:if>
</c:if>
<c:if test="${estType=='COOPERATOR'}">
	<c:if test="${currentUser.user.userType==1 || fn:indexOf(currentUser.privs,';COOP_PRIC;')!=-1 && fn:indexOf(currentUser.privs,';NO_PRIC_EDIT;')==-1}"><c:set var="canOper" value="Y" /></c:if>
</c:if>
<%@ include file="../inc/Title.jsp"%>
<head>
<link rel="stylesheet" type="text/css" href="/css/base.css" />
<link href="/css/Query.css" rel="stylesheet" type="text/css">
<script src="/js/QueryList.js"></script>
<script src="/js/popup_ext.js"></script>
<script language="javascript">
	function doNew(priceType){
		var url="/base/EstPriceNew.ihtm?est_type=${estType}&price_type=EST&est_id=${estId}";
		ShowIframe("项目价格",url,1024,400,"refreshWin()",900,600);
	}
	function refreshWin(){
		if(popRetVal!=null){
			window.location.reload(true);
		}
	}
	function doEdit(id){
		var url="/base/EstPriceEdit.ihtm?id="+id;
		ShowIframeNoScroll("项目价格",url,400,500,"refreshWin()",900,600);
	}
	function doSearch(){
		var mtId=document.getElementById("mt_id").value;
		var proName=document.getElementById("pro_name").value.trim();
		if(proName=="以材质名称或材质的拼音字头进行模糊查询"){
			proName="";
		}else{
			proName=encodeURIComponent(proName);
		}
		window.location="/base/EstPriceListForEst.ihtm?est_type=${estType}&est_id=${estId}&mt_id="+mtId+"&pro_name="+proName;
	}
	function doGo(pageIndex){
		var proName=encodeURIComponent("${proName}");
		window.location="/base/EstPriceListForEst.ihtm?est_type=${estType}&mt_id=${mtId}&est_id=${estId}&pro_name="+proName+"&current_page="+pageIndex;
	}
	function doJump(pageIndex){
		if(window.event.keyCode==13){
			doGo(pageIndex);
		}
	}
	function DoubleClick(it){
		var ob_arr = document.getElementsByName("query_checkbox");
		var str="";
		if(ob_arr.length>=it.getAttribute("index")){
			str=ob_arr[it.getAttribute("index")-1].value;
		}
		if(str==""){
			return;
		}
		doEdit(str);
	}
	function checkProName(){
		if(window.event.keyCode==13){
			doSearch();
		}
	}
	function proNameFocus(){
		if(document.getElementById("pro_name").value=="以材质名称或材质的拼音字头进行模糊查询"){
			document.getElementById("pro_name").value="";
		}
	}
	function proNameBlur(){
		if(document.getElementById("pro_name").value==""){
			document.getElementById("pro_name").value="以材质名称或材质的拼音字头进行模糊查询";
		}
	}
	function doDelete(id){
		ShowConfirm('确认框','确定删除吗？',340,80,"doDelAct('"+id+"')");
	}
	function doDelAct(id){
		if(popRetVal!=null){
			window.location="/base/EstPriceDelete.ihtm?est_type=${estType}&id="+id+"&from_url="+encodeURIComponent(window.location);
		}
	}
	function doInit(){
		document.getElementById("pro_name").focus();
	}
	function getMultiId(){
		var ob_arr = document.getElementsByName("query_checkbox");
		var str="";
		for (i=0;i<ob_arr.length;i++){
			if ((ob_arr[i].checked == true)){
				if(str!=""){
					str=str+";";
				}
				str = str+ob_arr[i].value;
			}
		}
		return str;
	}
	function doMultiDelete(){
		var str=getMultiId();
		if(str==""){
			ShowAlert('提示框','请选择要删除的记录!',200,100);
		}else{
			doDelete(str);
		}
	}
	function doImpo(){
		var estType="${estType}";
		var epType="";
		if(estType=='CLIENT'){
			epType="CLIE";
		}else if(estType=='COOPERATOR'){
			epType="COOP";
		}
		var formUrl="/base/EstPricImpoForm.ihtm?est_id=${est.id}&type="+epType;
		var targetUrl="/base/EstPricImpo.ihtm?est_id=${est.id}&type="+epType;
		ShowIframe("导入Excel",formUrl,560,300,"doImpoCallBack('"+targetUrl+"')");
	}
	function doImpoCallBack(targetUrl){
		if(popRetVal){
			document.getElementById("LoadProcess").style.top=(document.body.clientHeight/2-50)+"px";
			document.getElementById("LoadProcess").style.left=(document.body.clientWidth/2-100)+"px";
			document.getElementById("LoadProcess").style.display="";
			var fileName = popRetVal;
			var url;
			if(targetUrl.indexOf("?")==-1){
				url=targetUrl+"?file_name=" + encodeURIComponent(fileName);
			}else{
				url=targetUrl+"&file_name=" + encodeURIComponent(fileName);
			}
			var xmlHttp=createXMLHttpRequest();
			xmlHttp.open("GET", url, true);
			xmlHttp.onreadystatechange = function(){
				if (xmlHttp.readyState == 4) {
		      		if (xmlHttp.status == 200) {
			      		document.getElementById("LoadProcess").style.display="none";
			      		ShowIframe("导入Excel","/ImpoSuccess.ihtm",560,300,"doImpoCallBackExt()");
		      		}
		      	}
		    };
		    xmlHttp.send(null);
		}
	}
	function doImpoCallBackExt(){
		window.location.reload(true);
	}
</script>
</head>
<body class="sheet" style="padding-top:10px;text-align:center;" onLoad="doInit();">
<div class="sheet-main" style="width:860px;text-align:left;margin:auto;">
  <div class="sheet-top">
    <div class="content">
      <h2>${est.estName}</h2>
      <p>项目价格目录</p>
    </div>
  </div>
  <div class="sheet-list">
    <div class="search-business">
		 <div class="content">
	        <table width="748">
	          <tbody>
	            <tr>
	              <td  align="right">
	              	<select name="mt_id" id="mt_id" style="width:200px">
						<option value="0">请选择项目类型</option>
						<commonTag:createSelectTree list="${mtList}" emptyOption="0" defaultValue="${mtId}" />
				  	</select>
		            <input type="text" class="TextBox" id="pro_name" name="pro_name" onKeyUp="checkProName();" onfocus="proNameFocus();" onblur="proNameBlur();" style="width:100px" <c:if test="${proName==null || proName==''}">value="以材质名称或材质的拼音字头进行模糊查询"</c:if><c:if test="${proName!=null && proName!=''}">value="${proName}"</c:if> title="以材质名称或材质的拼音字头进行模糊查询">
		            <input type="button" class="buttom search-but" value=" 查 询" onClick="doSearch();">
					<input id="sDelButton" name="sDelButton" value=" 删 除" type="button" class="buttom search-remo" onclick="javascript:doMultiDelete();" />
					<c:if test="${canOper=='Y'}">
						<input type="button" value=" 导 入" onClick="doImpo();" class="buttom search-out" >
					  	<input type="button" value=" 新 增" onClick="doNew();" class="buttom search-add" >
					</c:if>
				  </td>
	            </tr>    
	           </tbody>      
	        </table>
	      </div>
		 <%@include file="../inc/AlertMsg.jsp"%>
	     <div class="table-list">
	        <table width="100%">
	          <tr>
	          	<th width="14"><input type="checkbox" onClick="javascript:checkall(this);"></th>
				<th width="12%">项目类型</th>
				<th width="14%">材质</th>
				<th width="14%">规格</th>
				<th width="10%">单位</th>
				<th width="10%">单价</th>
				<th width="16%">制作要求</th>
				<c:if test="${canOper=='Y'}">
					<th width="12%" >备注</th>
					<th width="12%" >操作</th>
				</c:if>
				<c:if test="${canOper!='Y'}">
					<th width="24%" >备注</th>
				</c:if>
			 </tr>
			<c:forEach var="item" items="${qr.list}" varStatus="i">
			<c:if test="${(i.index mod 2)==0}"><c:set var="trClass" value="query_list_data_tr1" /></c:if>
			<c:if test="${(i.index mod 2)!=0}"><c:set var="trClass" value="query_list_data_tr2" /></c:if>
			<tr class="${trClass}" index="${i.index+1}" style='cursor:pointer;' ondblclick='javascript:DoubleClick(this)' onClick='javascript:ClickCheck(this,true)' onmouseout='javascript:mouseout(this)' onmouseover='javascript:mouseover(this)'>
				<td><input type="checkbox" onClick="javascript:ClickCheck(this,true);" name='query_checkbox' value="${item[0]}"></td>
				<td>${item[1]}</td>
				<td>${item[2]}</td>
				<td>${item[9]}</td>
				<td>${item[3]}</td>
				<td>${item[4]}</td>
				<td>${item[5]}</td>
				<td>${item[6]}</td>
				<c:if test="${canOper=='Y'}">
					<td>
						<c:if test="${item[10]!=null && item[10]!=''}"><a href="${item[10]}" target="_blank">图片</a></c:if>
						<a href="javascript:doEdit('${item[0]}');">编辑</a>
						<a href="javascript:doDelete('${item[0]}');">删除</a>
					</td>
				</c:if>
			</tr>
			</c:forEach>
		</table>
		<%@include file="../inc/Pages.jsp"%>
     </div>  
   </div>  
  </div>
<div class="blank12"></blank>
</div>
<%@ include file="../inc/LoadingDiv.jsp"%>
</body>
</html>